﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace QuanLyKhachHang.Data
{
    class TTSoft
    {
        public string Soft, MaKhachHang, TenPhanMem,  GhiChu, MaNhanVien;
        public DateTime ThoiGian;
        public TTSoft() { }
        public TTSoft(string Soft, string MaKhachHang, string TenPhanMem, DateTime Thoigian, string GhiChu, string MaNhanVien)
        {
            this.Soft = Soft;
            this.MaKhachHang = MaKhachHang;
            this.TenPhanMem = TenPhanMem;
            this.ThoiGian = Thoigian;
            this.GhiChu = GhiChu;
            this.MaNhanVien = MaNhanVien;
        }

    }

    class NVSoft
    {
        public static DataTable ChonTatCa()
        {
            return Connect.cnSQL.ExecQuery("Select * from Soft");
        }
        public static DataTable ChonTatCa(string MaKhachHang)
        {
            return Connect.cnSQL.ExecQuery("SELECT Soft.*, NhanVien.TenNhanVien  FROM NhanVien RIGHT OUTER JOIN Soft ON NhanVien.MaNhanVien = Soft.MaNhanVien where MaKhachHang='" + MaKhachHang +"'");
        }
        public static bool Them(TTSoft Soft)
        {
            Connect.cnSQL.ExecNonQuery("Insert into Soft values('" + Soft.Soft + "','" + Soft.MaKhachHang + "',N'" + Soft.TenPhanMem + "',convert(datetime, '" + Soft.ThoiGian + "', 103) ,N'" + Soft.GhiChu + "','" + Soft.MaNhanVien + "')");
            return (!Connect.Tools.CoLoi);
        }
        public static bool Sua(TTSoft Soft)
        {
            Connect.cnSQL.ExecNonQuery("Update Soft Set MaKhachHang='" + Soft.MaKhachHang + "', TenPhanMem=N'" + Soft.TenPhanMem + "', ThoiGian=convert(datetime, '" + Soft.ThoiGian + "', 103),GhiChu=N'" + Soft.GhiChu + "', MaNhanVien='" + Soft.MaNhanVien + "'  where Soft='" + Soft.Soft + "'");
            return (!Connect.Tools.CoLoi);
        }
        public static bool Xoa(string Ma)
        {
            Connect.cnSQL.ExecNonQuery("Delete Soft where Soft ='" + Ma + "'");
            return (!Connect.Tools.CoLoi);
        }
    }
}
